<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的活动</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <header class="header header-shadow">
        <div class="header-left">
            <div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>
            </div>
        </div>
        <h2>我的活动</h2>
    </header>
</div>
<div class="header-h" style="padding-top: 1.5rem;"></div>
<section class="html_section pr30 pl30 setting_html">
    <div class="activity-list">
        <ul id="detail">
            <!--<li class="list-li" style="border-bottom:1px solid #f0f0f0">
                <div class="flex-div">
                    <div class="act-img bg-cover" style="background-image: url('../../image/img-activity.png')"></div>
                    <div class="act-info">
                        <h6 class="single-ellipsis">音乐爱好者，一起为音乐疯狂起来</h6>
                        <div class="act-time">
                            <p class="time">周日 09/29 14:00</p>
                            <p class="status status1">报名中</p>
                        </div>
                        <div class="act-place">
                            <p class="place">重庆大学城</p>
                            <p class="num">9/10</p>
                        </div>
                    </div>
                </div>
                <div class="detail-bottom">
                    <div class="bottom-tips">
                        <span class="bt-pd toUp">精选</span>
                        <span class="bt-pd tips">#读书会#</span>
                        <div class="bottom-hot">3.3w</div>
                    </div>
                </div>
            </li>-->
        </ul>
    </div>
    <div class="activity_eva_box">
        <div class="t-c b f36">活动已结束</div>
        <div class="t-c mt10 f30 c-999">请评价一下此次活动感受吧</div>
        <ul class="eva_lvl" id="eva_lvl">
            <li class="on" data-val="1"></li>
            <li class="on" data-val="2"></li>
            <li class="on" data-val="3"></li>
            <li class="on" data-val="4"></li>
            <li class="on" data-val="5"></li>
        </ul>
    </div>
    <div class="common-fixed-bottom">
        <a href="javascript:void(0);" tapmode onclick="submitEvaluate()" class="fixed-bottom">提交</a>
    </div>

</section>

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var activity_id = '';//活动id
    var status = '';//是否操作评星
    var evaluate = 5;//默认五星
    var type = '';//是否评星
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading();
        keybackListener()
        activity_id = api.pageParam.activity_id;
        status = api.pageParam.status;
        if (status == 1) {
            $(".common-fixed-bottom").show();
            type = 2
        } else {
            $(".common-fixed-bottom").hide();
            type = 1
        }
        getActivity()
    }

    //活动评星提交
    function submitEvaluate() {
        var param = {
            token: $api.getStorage('token'),
            activity_id: activity_id,
            evaluate: evaluate
        }
        pop.loading()
        getAjax(Interface.activity_evaluate, param, function (res) {
            pop.notice(res.msg)
            pop.close()
            setTimeout(function () {
                comeBack()
                api.sendEvent({
                    name: 'evaluate',
                    extra: {}
                });
            }, 1000)
        }, function (error) {
            pop.notice(error.msg)
            pop.close()
        })
    }


    //获取活动详情
    function getActivity() {

        var param = {
            token: $api.getStorage('token'),
            activity_id: activity_id,
            type: type,
        }
        getAjax(Interface.activity_pone, param, function (res) {
            var listData = res.data.list;

            if (isDefine(listData.evaluate_status)) {
                if (listData.evaluate_status == 1) {
                    evaluate = res.data.evaluate.evaluate;
                    var starHtml = '';
                    for (var i = 0; i < evaluate; i++) {
                        starHtml += '<li class="on"></li>'
                    }
                    var nostar = 5 - parseInt(evaluate);
                    for (var j = 0; j < nostar; j++) {
                        starHtml += '<li class=""></li>'
                    }
                    console.log(starHtml)
                    $("#eva_lvl").html(starHtml)
                }
            }

            var listHtml = '';
            var actHtml = '';//活动内容
            var actStatus = '';//活动状态
            var toUp = '';//是否精选
            var hotHtml = '';
            var tips = '';//标签
            if (isDefine(listData)) {

                //顶置，标签，热度
                if (listData.recommend == 1) {
                    toUp = '<span class="bt-pd toUp">精选</span>';
                }
                if (isDefine(listData.cut_list)) {
                    for (var z = 0; z < listData.cut_list.length; z++) {
                        tips += '<span class="bt-pd tips">#' + listData.cut_list[z] + '#</span>'
                    }
                }

                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp + tips + '</div>' +
                    '              <div class="bottom-hot">' + listData.hot_number + '</div>' +
                    '</div>';

                if (listData.status == 1) {
                    actStatus = '<p class="status status1">报名中</p>'
                } else if (listData.status == 2) {
                    actStatus = '<p class="status status3">进行中</p>'
                } else if (listData.status == 3) {
                    actStatus = '<p class="status status2">已结束</p>'
                } else {
                    actStatus = '<p class="status status2">已取消</p>'
                }
                var activity = {'activity_id': listData.id};
                actHtml = '<div class="flex-div" tapmode onclick=\'commonUrl("../activity/activity_index",' + jsonChange(activity) + ')\'>' +
                    '                    <div class="act-img bg-cover" style="background-image: url(' + ajaxUrl + listData.icons_path[0] + ')"></div>' +
                    '                    <div class="act-info">' +
                    '                        <h6 class="single-ellipsis">' + listData.title + '</h6>' +
                    '                        <div class="act-time">' +
                    '                            <p class="time">' + listData.week + ' ' + listData.start_date + '</p>' + actStatus + '</div>' +
                    '                        <div class="act-place">' +
                    '                            <p class="place">' + listData.address + '</p>' +
                    '                            <p class="num">' + listData.sum_number + '/' + listData.number + '</p>' +
                    '                        </div>' +
                    '                    </div>' +
                    '                </div>';

                listHtml = '<li style="border-bottom: 1px #f0f0f0 solid;" class="list-li">' + actHtml + hotHtml + '</li>';


                $("#detail").html(listHtml);
            }
            pop.close()
        }, function (error) {
            pop.notice(error.msg)
            pop.close()
        })
    }


    //选择星级
    $(".eva_lvl").on('click', 'li', function () {
        if (status == 1) {
            $(".eva_lvl li").removeClass("on");
            var length = $(this).data("val");
            for (var i = 0; i < length; i++) {
                $(".eva_lvl li").eq(i).addClass("on");
                evaluate = length;
            }
        }
    })


</script>
